﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;

namespace WebApp.Services
{
    public class CowSocket
    {
        private Socket _socket;
        //private int ThreadId = 0;//调用者身份
        public CowSocket()
        {
            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        }
        public void Bind(EndPoint iep)
        {
            _socket.Bind(iep);
        }

        public bool IsBusy { get; private set; }
        public int Send(byte[] buffer)
        {
            IsBusy = true;
            return _socket.Send(buffer);
        }

        public int Revice(byte[] buffer)
        {
            return _socket.Receive(buffer);
        }

        public void Release()
        {
            IsBusy = false;
        }
    }
}
